export default {
    back: () => {
        let pages = getCurrentPages()
        let prePage = pages[pages.length - 2] || null
        // #ifndef H5
        prePage = prePage ? prePage.$vm : null
        // #endif
        if (prePage) {
            uni.navigateBack()
        } else {
            uni.switchTab({
                url: '/pages/index/index'
            })
        }
    },
    to: (url) => {
        uni.navigateTo({
            url: url
        })
    },
    switchTab: (url) => {
        uni.switchTab({
            url: url
        })
    },
    formatPrice: (price) => {
        const formatted = parseFloat(price / 100).toFixed(2);
        // 当小数部分都是0时，去掉小数点和0
        return formatted.endsWith('.00') ? formatted.split('.')[0] : formatted;
    }
}